package com.wxc.wxcwzq.core.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.wxc.wxcwzq.core.entity.Employee;
import com.wxc.wxcwzq.core.mapper.EmployeeMapper;
import com.wxc.wxcwzq.web.entity.SysUser;
import com.wxc.wxcwzq.web.mapper.SysUserMapper;

@Service
public class EmployeeService {

	@Autowired
	private EmployeeMapper mapper;
	
	public Page<Employee> getEmployeesList(Employee employee,Integer pageNum, Integer pageSize){
//		Page<Employee> page = new Page<>();
		PageHelper.startPage(pageNum,pageSize);
		Page <Employee> list = mapper.selectUserInfo(employee);
		return list;
	}
	
	//添加用户
	public Integer addOrUpdate(Employee employee){
		Integer number;
		if(employee.getId()!=null&&!"".equals(employee)){
			//修改
			number = mapper.updateByPrimaryKeySelective(employee);
		}else{
			//添加
			number = mapper.insertSelective(employee);
		}
		return number;
	}
	
	//删除用户
	public Integer deleteUserById(Long id){
		Integer i = mapper.deleteByPrimaryKey(id);
		return i;
	}
}
